<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

</body>
<script>
    class Vue{
        constructor(options){
            // console.log(options.data.num);
            this.initProxy(options.data);
        }
         //定义一个方法进行数据劫持
        initProxy(data){
           Object.keys(data).map(v=>{//循环data的keys键
            //    console.log(data[v]);
               Object.defineProperty(this,v,{
                   get:function(){
                       return data[v];
                   },
                   set:function(newVal){
                       data[v].newVal;
                   }
               })
           })
            
        }
    }
    var vm = new Vue({
        data:{
            num:111
        }
    });
    console.log(vm.num);
</script>
</html>